package org.reward;

import java.util.Arrays;
import java.util.Random;

/**
 * @Author: xwg
 * @CreateDate: 2021/11/27
 */

// 生产产品 生产10连抽的结果
public class Core {
    public static final String YELLOW = "黄色";
    public static final String PURPLE="紫色";
    public static final String GOLD="金色";

//     [  黄色75，紫色93 ]
//    [0-80）黄色，[80-99)紫色,[99,100)金色
//    十连抽 保底一个紫色品质以上的
    public String[] produceTen(){

        Boolean purpleAbove =false;
        String[] results = new String[10];
        Random random = new Random();
        for (int i = 0; i < results.length; i++) {
            String one = null;
            int randomInt = random.nextInt(100);
            if (randomInt<80){
                one=YELLOW;
            }else if(randomInt<99){
                one=PURPLE;
                purpleAbove=true;
            }else {
                one=GOLD;
                purpleAbove=true;
            }
            results[i]=one+randomInt;
        }
//        如果10连循环抽奖完毕 都没有一次抽到紫色或金色
        if (!purpleAbove){
            results[results.length-1]=PURPLE+9999;
        }
        return results;
    }

    public static void main(String[] args) {
        Core core = new Core();
        String[] r = core.produceTen();
        System.out.println(Arrays.toString(r));
    }
}
